{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "print 默认会在末尾换行，如果想取消换行，可以使用参数 end=\"\"。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "Hello, World!\n",
      "Hello, World!\n",
      "abc 10\n",
      "abc 10\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "\n",
    "# 输出：10\n",
    "print(a)\n",
    "\n",
    "# 串联输出（通过字符串拼接或逗号分隔）\n",
    "# 输出：Hello, World!\n",
    "print(\"Hello\" + \", \" + \"World!\")\n",
    "# 使用 sep 指定分隔符 相当于中间加了一个逗号\n",
    "print(\"Hello\", \"World!\", sep=\", \")\n",
    "\n",
    "s = \"abc\"\n",
    "# 输出：abc 10\n",
    "print(s, a)\n",
    "\n",
    "# 格式化输出\n",
    "# 输出：abc 10\n",
    "print(f\"{s} {a}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "def simple_input_output():\n",
    "    # 接收输入并存储到一个字符串变量中\n",
    "    user_input = input(\"请输入内容：\")\n",
    "\n",
    "    # 如果你确实需要一个单个字符，可以这样接收输入\n",
    "    # 由于Python中没有char类型，我们仍然使用字符串来存储单个字符\n",
    "    char_input = input(\"请输入一个字符：\")\n",
    "\n",
    "    # 打印输入的内容\n",
    "    print(\"你输入的内容是：\", user_input)\n",
    "    print(\"你输入的单个字符是：\", char_input)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你输入的内容是： \n",
      "你输入的单个字符是： \n"
     ]
    }
   ],
   "source": [
    "simple_input_output()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "science39",
   "language": "python",
   "name": "science39"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
